<!DOCTYPE html>
<html lang="en" id="ng-app" ng-app>
  <head>
    <meta charset="utf-8">
    <title>永远的20434班 - 写文章</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <script src="/dashboard/utils.js"></script>

    <!-- Le styles -->
    <link href="/bootstrap/css/bootstrap.css" rel="stylesheet">
    <link href="/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
    <style type="text/css">
      body {
        padding-top: 60px;
        padding-bottom: 40px;
      }
      .toolbar-fixed-top{
        position: fixed;
        top: 60px;
      }
      .background-color{
        border-color: rgb(237,237,237);
      }

      .boxsizingBorder {
        -webkit-box-sizing: border-box;
        -moz-box-sizing: border-box;
        box-sizing: border-box;
      }

    </style>
    

    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

  </head>

  <body>
    <div id="banner" class="navbar navbar-fixed-top navbar-inverse">
      <div class="navbar-inner">
        <div class="container">
          <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
            <span class="icon-bar"><image src="/icons/logo.png"/></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
          </a>
          <a class="brand" href="/">永远的20434</a>
          <div class="nav-collapse collapse">
            <ul class="nav">
              <li><a href="/artical/new">写文章</a></li>
              <li><a href="/albums">相册</a></li>
            </ul>
            <form class="navbar-search pull-right">
              <input class="search-query span3" type="text" placeholder="Type to search">
            </form>
          </div><!--/.nav-collapse -->
        <!--/div-->
      </div>
    </div>
  </div>

    <div class="container-fluid" id="contentContainer" ng-controller="ArticalNewCtrl" ng-init="getArticalContent()">

      <!-- Main hero unit for a primary marketing message or call to action -->
      <!--div class="hero-unit">
        <h1>Hello, world!</h1>
        <p>This is a template for a simple marketing or informational website. It includes a large callout called the hero unit and three supporting pieces of content. Use it as a starting point to create something more unique.</p>
        <p><a class="btn btn-primary btn-large">Learn more &raquo;</a></p>
      </div-->

      <!-- Example row of columns -->

    <div class="alert alert-block">
      <p>
        写文章的格式是<a hef="http://baike.baidu.com/view/2311114.htm">Markdown</a>，关于Markdown的详细说明请猛击<a href="http://wowubuntu.com/markdown/">Markdown 语法说明 (简体中文版)</a> So Easy!。
      </p>
      <div class="btn-group">
        <a href="/" class="btn btn-danger">放弃修改</a>
        <button ng-click="updateArtical()" class="btn btn-primary">发布</button>
      </div>
      
    </div>

      <div class="row-fluid"><!---outter row-fluid-->

      <div class="span6">
        <div class="row-fluid">
          <input id="artical_title" class="span12" type="text" placeholder="请输入文章标题（不超过50字）" ng-model="artical.title">
        </div>
        <div class="row-fluid">
          <textarea id="artical_markdown" class="span12" rows="25" placeholder="请输入文章内容（不少于50字）" ng-model="artical.articalMD">
          </textarea>
        </div>
      </div>

      <div class="span6">
        <div id="artical_html" class="span12" rows="27" ng-model="artical.articalHTML">
        </div>
      </div>

    </div> <!--outter row-fluid end-->
    </div> <!-- /container -->

    <div id="footer">
      <p class="muted credit">&copy; Utopia-Project All Rights Reserved.</p>
    </div>

     <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="/bootstrap/js/jquery.js"></script>
    <script src="/bootstrap/js/bootstrap-transition.js"></script>
    <script src="/bootstrap/js/bootstrap-alert.js"></script>
    <script src="/bootstrap/js/bootstrap-modal.js"></script>
    <script src="/bootstrap/js/bootstrap-dropdown.js"></script>
    <script src="/bootstrap/js/bootstrap-scrollspy.js"></script>
    <script src="/bootstrap/js/bootstrap-tab.js"></script>
    <script src="/bootstrap/js/bootstrap-tooltip.js"></script>
    <script src="/bootstrap/js/bootstrap-popover.js"></script>
    <script src="/bootstrap/js/bootstrap-button.js"></script>
    <script src="/bootstrap/js/bootstrap-collapse.js"></script>
    <script src="/bootstrap/js/bootstrap-carousel.js"></script>
    <script src="/bootstrap/js/bootstrap-typeahead.js"></script>
    <script src="/bootstrap/js/holder/holder.js"></script>
    <script src="/angularjs_1.0.7/angular.js"></script>
    <script src="/20434/artical_new_ctrl.js"></script>

    <script src="/pagedown/Markdown.Converter.js"></script>
    <script src="/pagedown/Markdown.Sanitizer.js"></script>

    <script>
      function convertMD2HTML(){
        var converter = new Markdown.Converter();
        var mdVal = $('#artical_markdown').val();
        var htmlVal = converter.makeHtml(mdVal);
        $('#artical_html').empty();
        $('#artical_html').append(htmlVal);   
      }

      var propertyChangeUnbound = false;
      $("#artical_markdown").on("propertychange", function(e) {
        if (e.originalEvent.propertyName == "value") {
            //add the process
            convertMD2HTML();
          }
      });

      $("#artical_markdown").on("input", function() {
        if (!propertyChangeUnbound) {
          $("#artical_markdown").unbind("propertychange");
          propertyChangeUnbound = true;
        }
        //add the process
        convertMD2HTML();
      });
    </script>

  </body>
</html>
